home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18538 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.1 KB

  1. Path: ix.netcom.com!news
  2. From: Bradd W. Szonye <bradds@ix.netcom.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: RE: Beginner: Some Questions
  5. Date: 20 Apr 1996 20:04:13 GMT
  6. Organization: Netcom
  7. Message-ID: <01bb2ef5.2ad6b540$8ec2b7c7@Zany.localhost>
  8. References: <N.041596.214427.72@slipper163167.bcs.iafrica.com>
  9. NNTP-Posting-Host: det-mi4-14.ix.netcom.com
  10. X-NETCOM-Date: Sat Apr 20  3:04:13 PM CDT 1996
  11. X-Newsreader: Microsoft Internet News
  12.  
  13.  
  14. On Monday, April 15, 1996, herbi@iafrica.com wrote...
  15. > Hi 
  16. > I am a C++ beginner. I programmed in T.Pascal, and now i need someting
  17. new. The 
  18. > basic commands in Pascal is the same as in C++.
  19. > I have some questions, i know how to do it in Pascal,but not in C++. If
  20. you 
  21. > can, could you perhaps answer them for me.
  22. > 1) How do you repeat a statement for a certen amout of times, or until a
  23. key is 
  24. > pressed?
  25.  
  26. To repeat a statement N times:
  27.  
  28. size_t i;
  29. for (i = 0; i < N; i++) {
  30.     // do stuff
  31. }
  32.  
  33. The second half is OS-specific, but for hints look in your compiler's help
  34. regarding the header <conio.h>, which exists under both MSVC++ and Borland
  35. C++ (I think).
  36.  
  37. > 2) How do you activate the mouse or mouse driver?
  38.  
  39. This is OS-specific and very complex. I suggest getting a good book on
  40. programming for Windows to learn about event-driven programming.
  41. "Programming Windows" by Charles Petzold is the "definitive" book, and
  42. "Inside Visual C++" by Kruglinski is good if you're using Visual C++. Make
  43. sure you get the right version of the book though--different editions are
  44. aimed at different Windows versions.
  45.  
  46. I'd recommend *not* learning how to program the mouse under DOS... it's
  47. fairly difficult and (hopefully) obsolete.
  48.  
  49. > 3) How do you open a text file, input data or read data?
  50.  
  51. If the maximum length of a line is N:
  52.  
  53. char buffer[N];
  54. ifstream istr("filename");
  55.  
  56. istr.getline(buffer, sizeof buffer);
  57. while (istr) {
  58.     // do stuff with text line
  59.     istr.getline(buffer, sizeof buffer);
  60. }
  61.  
  62. > 4) How do you get 256 colors in C++?
  63.  
  64. This is a topic which requires a bit of experience in Windows programming
  65. and is probably not worthwhile for DOS programming. In fact, learning
  66. anything for DOS programming with a fairly large learning curve may be a
  67. bad use of your time. Start learning how to program for Windows; if you're
  68. intending to do any kind of professional programming, you may need to.
  69.  
  70. > I you could answer this few questions it would help me a lot in
  71. programming. 
  72. > If you know of a site or ftp which have c++ source files or anything to
  73. do with 
  74. > C++ programming, could you give it to me please.
  75.  
  76. This is an area where you may actually want to visit Borders Books (or
  77. your favorite store) before consulting the Internet. With the current
  78. chaotic state of the C++ language, stuff on the Internet is very likely to
  79. be confusing and contradictory. This isn't because net users are idiots.
  80. Rather, any question like "how do I do this" or "is this legal" is likely
  81. to get different answers from Microsoft, Borland, gnu, Sun, HP, Watcom,
  82. etc. users. If you do ask questions, be sure to include which OS and
  83. compiler you're using, including the version.
  84.  
  85. > Thanks 
  86. > Cheers!!
  87. > email:herbi@iafrica.com
  88.  
  89.  
  90.